home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / ell.lha / ell / src / Tree.md < prev    next >
Text File  |  1992-08-18  |  10KB  |  221 lines

  1. DEFINITION MODULE Tree;
  2.  
  3. IMPORT SYSTEM, IO;
  4. (* line 12 "ell.ast" *)
  5.  
  6. FROM Idents    IMPORT    tIdent;
  7. FROM Sets    IMPORT    tSet;
  8. FROM StringMem    IMPORT    tStringRef;
  9. FROM Positions    IMPORT    tPosition;
  10. FROM SYSTEM    IMPORT    ADDRESS;
  11.  
  12. TYPE yyEstra = ADDRESS;
  13.  
  14.  
  15.  
  16. VAR ScannerName, ParserName: tIdent;
  17.  
  18.  
  19. CONST
  20. NoTree = NIL;
  21.  
  22. Grammar = 1;
  23. sections = 2;
  24. Sections0 = 3;
  25. Sections = 4;
  26. section = 5;
  27. Export = 6;
  28. Global = 7;
  29. Local = 8;
  30. Begin = 9;
  31. Close = 10;
  32. codes = 11;
  33. Codes0 = 12;
  34. Codes = 13;
  35. Code = 14;
  36. code = 15;
  37. tokens = 16;
  38. Tokens0 = 17;
  39. Tokens = 18;
  40. Token = 19;
  41. token = 20;
  42. Id = 21;
  43. id = 22;
  44. Number = 23;
  45. number = 24;
  46. rules = 25;
  47. Rules0 = 26;
  48. Rules = 27;
  49. Rule = 28;
  50. rule = 29;
  51. expr = 30;
  52. Option = 31;
  53. Times = 32;
  54. Plus = 33;
  55. List = 34;
  56. Action = 35;
  57. Leaf = 36;
  58. alternative = 37;
  59. Alternative0 = 38;
  60. Alternative = 39;
  61. sequence = 40;
  62. Sequence0 = 41;
  63. Sequence = 42;
  64.  
  65. TYPE tTree = POINTER TO yyNode;
  66. tProcTree = PROCEDURE (tTree);
  67.  
  68.  
  69. TYPE
  70. yytNodeHead = RECORD yyKind, yyMark: SHORTCARD; yyEstraInfo: yyEstra; END;
  71. yGrammar = RECORD yyHead: yytNodeHead; sections: tTree; tokens: tTree; rules: tTree; END;
  72. ysections = RECORD yyHead: yytNodeHead; END;
  73. ySections0 = RECORD yyHead: yytNodeHead; END;
  74. ySections = RECORD yyHead: yytNodeHead; sections: tTree; section: tTree; END;
  75. ysection = RECORD yyHead: yytNodeHead; END;
  76. yExport = RECORD yyHead: yytNodeHead; codes: tTree; END;
  77. yGlobal = RECORD yyHead: yytNodeHead; codes: tTree; END;
  78. yLocal = RECORD yyHead: yytNodeHead; codes: tTree; END;
  79. yBegin = RECORD yyHead: yytNodeHead; codes: tTree; END;
  80. yClose = RECORD yyHead: yytNodeHead; codes: tTree; END;
  81. ycodes = RECORD yyHead: yytNodeHead; END;
  82. yCodes0 = RECORD yyHead: yytNodeHead; END;
  83. yCodes = RECORD yyHead: yytNodeHead; codes: tTree; code: tTree; END;
  84. yCode = RECORD yyHead: yytNodeHead; pos: tPosition; ref: tStringRef; END;
  85. ycode = RECORD yyHead: yytNodeHead; pos: tPosition; ref: tStringRef; END;
  86. ytokens = RECORD yyHead: yytNodeHead; END;
  87. yTokens0 = RECORD yyHead: yytNodeHead; END;
  88. yTokens = RECORD yyHead: yytNodeHead; tokens: tTree; token: tTree; END;
  89. yToken = RECORD yyHead: yytNodeHead; id: tTree; number: tTree; END;
  90. ytoken = RECORD yyHead: yytNodeHead; id: tTree; number: tTree; END;
  91. yId = RECORD yyHead: yytNodeHead; pos: tPosition; ident: tIdent; isstring: BOOLEAN; END;
  92. yid = RECORD yyHead: yytNodeHead; pos: tPosition; ident: tIdent; isstring: BOOLEAN; END;
  93. yNumber = RECORD yyHead: yytNodeHead; pos: tPosition; value: INTEGER; END;
  94. ynumber = RECORD yyHead: yytNodeHead; pos: tPosition; value: INTEGER; END;
  95. yrules = RECORD yyHead: yytNodeHead; END;
  96. yRules0 = RECORD yyHead: yytNodeHead; END;
  97. yRules = RECORD yyHead: yytNodeHead; rules: tTree; rule: tTree; END;
  98. yRule = RECORD yyHead: yytNodeHead; pos: tPosition; id: tTree; codes: tTree; expr: tTree; iscalling: BOOLEAN; END;
  99. yrule = RECORD yyHead: yytNodeHead; pos: tPosition; id: tTree; codes: tTree; expr: tTree; iscalling: BOOLEAN; END;
  100. yexpr = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; END;
  101. yOption = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; expr: tTree; END;
  102. yTimes = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; expr: tTree; END;
  103. yPlus = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; expr: tTree; END;
  104. yList = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; body: tTree; sep: tTree; END;
  105. yAction = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; codes: tTree; END;
  106. yLeaf = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; id: tTree; sure: BOOLEAN; number: INTEGER; END;
  107. yalternative = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; depth: INTEGER; case: BOOLEAN; END;
  108. yAlternative0 = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; depth: INTEGER; case: BOOLEAN; recover: BOOLEAN; default: tTree; END;
  109. yAlternative = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; depth: INTEGER; case: BOOLEAN; alternative: tTree; expr: tTree; END;
  110. ysequence = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; END;
  111. ySequence0 = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; END;
  112. ySequence = RECORD yyHead: yytNodeHead; pos: tPosition; first: tSet; follow: tSet; fifo: tSet; recovery: tSet; length: INTEGER; index: INTEGER; followindex: INTEGER; recindex: INTEGER; expindex: INTEGER; sequence: tTree; expr: tTree; END;
  113.  
  114. yyNode = RECORD
  115. CASE : SHORTCARD OF
  116. | 0: Kind: SHORTCARD;
  117. | 43: yyHead: yytNodeHead;
  118. | Grammar: Grammar: yGrammar;
  119. | sections: sections: ysections;
  120. | Sections0: Sections0: ySections0;
  121. | Sections: Sections: ySections;
  122. | section: section: ysection;
  123. | Export: Export: yExport;
  124. | Global: Global: yGlobal;
  125. | Local: Local: yLocal;
  126. | Begin: Begin: yBegin;
  127. | Close: Close: yClose;
  128. | codes: codes: ycodes;
  129. | Codes0: Codes0: yCodes0;
  130. | Codes: Codes: yCodes;
  131. | Code: Code: yCode;
  132. | code: code: ycode;
  133. | tokens: tokens: ytokens;
  134. | Tokens0: Tokens0: yTokens0;
  135. | Tokens: Tokens: yTokens;
  136. | Token: Token: yToken;
  137. | token: token: ytoken;
  138. | Id: Id: yId;
  139. | id: id: yid;
  140. | Number: Number: yNumber;
  141. | number: number: ynumber;
  142. | rules: rules: yrules;
  143. | Rules0: Rules0: yRules0;
  144. | Rules: Rules: yRules;
  145. | Rule: Rule: yRule;
  146. | rule: rule: yrule;
  147. | expr: expr: yexpr;
  148. | Option: Option: yOption;
  149. | Times: Times: yTimes;
  150. | Plus: Plus: yPlus;
  151. | List: List: yList;
  152. | Action: Action: yAction;
  153. | Leaf: Leaf: yLeaf;
  154. | alternative: alternative: yalternative;
  155. | Alternative0: Alternative0: yAlternative0;
  156. | Alternative: Alternative: yAlternative;
  157. | sequence: sequence: ysequence;
  158. | Sequence0: Sequence0: ySequence0;
  159. | Sequence: Sequence: ySequence;
  160. END;
  161. END;
  162.  
  163. VAR TreeRoot    : tTree;
  164. VAR HeapUsed    : LONGCARD;
  165. VAR yyPoolFreePtr, yyPoolMaxPtr    : SYSTEM.ADDRESS;
  166. VAR yyNodeSize    : ARRAY [0..42] OF SHORTCARD;
  167. VAR yyExit    : PROC;
  168.  
  169. PROCEDURE yyAlloc    (): tTree;
  170. PROCEDURE MakeTree    (Kind: SHORTCARD): tTree;
  171. PROCEDURE IsType    (Tree: tTree; Kind: SHORTCARD): BOOLEAN;
  172.  
  173. PROCEDURE mGrammar (psections: tTree; ptokens: tTree; prules: tTree): tTree;
  174. PROCEDURE msections (): tTree;
  175. PROCEDURE mSections0 (): tTree;
  176. PROCEDURE mSections (psections: tTree; psection: tTree): tTree;
  177. PROCEDURE msection (): tTree;
  178. PROCEDURE mExport (pcodes: tTree): tTree;
  179. PROCEDURE mGlobal (pcodes: tTree): tTree;
  180. PROCEDURE mLocal (pcodes: tTree): tTree;
  181. PROCEDURE mBegin (pcodes: tTree): tTree;
  182. PROCEDURE mClose (pcodes: tTree): tTree;
  183. PROCEDURE mcodes (): tTree;
  184. PROCEDURE mCodes0 (): tTree;
  185. PROCEDURE mCodes (pcodes: tTree; pcode: tTree): tTree;
  186. PROCEDURE mCode (ppos: tPosition; pref: tStringRef): tTree;
  187. PROCEDURE mcode (ppos: tPosition; pref: tStringRef): tTree;
  188. PROCEDURE mtokens (): tTree;
  189. PROCEDURE mTokens0 (): tTree;
  190. PROCEDURE mTokens (ptokens: tTree; ptoken: tTree): tTree;
  191. PROCEDURE mToken (pid: tTree; pnumber: tTree): tTree;
  192. PROCEDURE mtoken (pid: tTree; pnumber: tTree): tTree;
  193. PROCEDURE mId (ppos: tPosition; pident: tIdent; pisstring: BOOLEAN): tTree;
  194. PROCEDURE mid (ppos: tPosition; pident: tIdent; pisstring: BOOLEAN): tTree;
  195. PROCEDURE mNumber (ppos: tPosition; pvalue: INTEGER): tTree;
  196. PROCEDURE mnumber (ppos: tPosition; pvalue: INTEGER): tTree;
  197. PROCEDURE mrules (): tTree;
  198. PROCEDURE mRules0 (): tTree;
  199. PROCEDURE mRules (prules: tTree; prule: tTree): tTree;
  200. PROCEDURE mRule (ppos: tPosition; pid: tTree; pcodes: tTree; pexpr: tTree): tTree;
  201. PROCEDURE mrule (ppos: tPosition; pid: tTree; pcodes: tTree; pexpr: tTree): tTree;
  202. PROCEDURE mexpr (ppos: tPosition): tTree;
  203. PROCEDURE mOption (ppos: tPosition; pexpr: tTree): tTree;
  204. PROCEDURE mTimes (ppos: tPosition; pexpr: tTree): tTree;
  205. PROCEDURE mPlus (ppos: tPosition; pexpr: tTree): tTree;
  206. PROCEDURE mList (ppos: tPosition; pbody: tTree; psep: tTree): tTree;
  207. PROCEDURE mAction (ppos: tPosition; pcodes: tTree): tTree;
  208. PROCEDURE mLeaf (ppos: tPosition; pid: tTree): tTree;
  209. PROCEDURE malternative (ppos: tPosition): tTree;
  210. PROCEDURE mAlternative0 (ppos: tPosition): tTree;
  211. PROCEDURE mAlternative (ppos: tPosition; palternative: tTree; pexpr: tTree): tTree;
  212. PROCEDURE msequence (ppos: tPosition): tTree;
  213. PROCEDURE mSequence0 (ppos: tPosition): tTree;
  214. PROCEDURE mSequence (ppos: tPosition; psequence: tTree; pexpr: tTree): tTree;
  215.  
  216. PROCEDURE ReverseTree    (Tree: tTree): tTree;
  217. PROCEDURE BeginTree;
  218. PROCEDURE CloseTree;
  219.  
  220. END Tree.
  221.